// add map area panelId
var dopBtnAdd = "";
var dopBtnAssign = "";
var mapManager = null;
var isModify = false;
var userError=$("#userError");
/**
 * 获取根路径basePath
 * @type 
 */
var obj=window.location; 
var contextPath=obj.pathname.split("/")[1]; 
var basePath="";
if(contextPath.indexOf(".do")==-1){
	basePath=obj.protocol+"//"+obj.host+"/"+contextPath; 
}else{
	basePath=obj.protocol+"//"+obj.host;
}

$(function(){
	$("#companyDesc").val($("#descHide").val());
	$("#isDeliveryMan").combobox("select","1");
});
$("#dop_datagrid_deliveryMan").datagrid({
	url : "",
	height : 450,
	pagination : true,
	fitColumns : true,
	singleSelect : false,
	fit : false,
	pageSize : 10,
	pageList : [10, 30, 50, 100],
	rownumbers : true,
	showFooter : true,
	frozenColumns : [[]],
	columns : [ [ {
		field : 'ck',
		checkbox : true
	}, {
		field : "id",
		width : 150,
		title : "主键",
		hidden : true
	}, {
		field : "delName",
		width : 150,
		title : "员工姓名",
		align:'center',
		hidden : true
	}, {
		field : "sUserName",
		width : 150,
		title : "员工姓名",
		align:'center'
	},{
		field : "statusText",
		width : 150,
		title : "接单状态",
		align:'center'
	},  {
		field : "enabledName",
		width : 150,
		title : "在职状态",
		align:'center'
	}, {
		field : "isDeliveryManText",
		width : 150,
		title : "是否为配送员",
		align:'center'
	}, {
		field : "delCertificates",
		width : 150,
		title : "身份证号",
		halign:"center",
		align:'left'
	}, {
		field : "delTelephone",
		width : 150,
		title : "手机",
		halign:"center",
		align:'left'
	}, {
		field : "delIntroduction",
		width : 150,
		title : "备注",
		hidden : true
	} ,{
		field : "delPortrait",
		width : 150,
		title : "照片",
		hidden : true
	} ] ],
	toolbar:"#tbar"
	
});

init();
$("#roleList").datagrid({
	url : "",
	loadMsg: '正在加载角色信息...',
	height : 350,
	pagination : true,
	fitColumns : false,
	singleSelect : false,
	fit : true,
	pageSize : 10,
	pageList : [ 10],
	sortOrder : 'desc',
	rownumbers : true,
	showFooter : true,
	columns : [[{
			field : 'ck',
			checkbox : true
		},
		{
			field:'id',
			title:'编号',
			hidden:true,
			
			sortable:true
		},
		{
			field:'roleName',
			title:'角色名称',
			halign:"center",
			width:100,
			sortable:true
		}
	]],
	toolbar:"#roleTool"
});

$("#roleWindow").window({
    width:400,
    height:430,
    modal:true
});

// click pagination
var p = $("#dop_datagrid_deliveryMan").datagrid('getPager');
$(p).pagination(
		{
			onSelectPage : function(pageNumber, pageSize) {
				var params = $.extend({
					pageNum : pageNumber,
					pageSize : pageSize
				}, getQueryParams());
				EapTools.doAction("deliveryCompanyController.do?queryManList", params,
						true, function(data) {
							$("#dop_datagrid_deliveryMan").datagrid('loadData',
									{
										"rows" : data.list,
										"total" : data.count
									} || {});
						});
			}
		});

var rolep = $("#roleList").datagrid('getPager');
$(rolep).pagination(
		{
		onSelectPage : function(pageNumber, pageSize) {
			var params = $.extend({
				pageNum : pageNumber,
				pageSize : pageSize
			});
			var role=$("input[code='roleName']").val();
			EapTools.doAction("userController.do?datagridRole&field=id,roleName,", {roleName:role},
					true, function(data) {
						$("#roleList").datagrid('loadData',
								{
									"rows" : data.rows,
									"total" : data.total
								} || {});
						
				});
		}
	});

/**
 * 加载角色信息
 */
initRole();
function initRole(){
		var role=$("input[code='roleName']").val();
		var options = $("#roleList").datagrid('getPager').data(
			"pagination").options;
		var pageSize = options.pageSize;
		var params = {
			pageNum : 1,
			pageSize : pageSize,
			roleName:role
		};
		EapTools.doAction("roleController.do?getRoleByPage", params,
				true, function(data) {
					$("#roleList").datagrid('loadData',
							{
								"rows" : data.rows,
								"total" : data.total
							} || {});
				});
}

/**
 * 弹出角色列表
 */
function selectRole(){
	$("#roleWindow").show();
	initRole();
	$("#roleWindow").window("open");
}

$("#roleOk").click(function(){
	var selections = $("#roleList").datagrid(
		"getSelections");
	var roleId="";
	var roleName="";
	if(selections.length>0){
		for(var i=0;i<selections.length;i++){
			roleId+=","+selections[i].id;
			roleName+=","+selections[i].roleName;
		}
		$("#roleName").val(roleName.substring(1));
		$("#roleId").val(roleId.substring(1));
		$("#roleWindow").window("close");
		$(".textbox").attr("class","textbox");
		$(".Validform_wrong").hide();
	}
});

$("#roleCancel").click(function(){
	$("#roleWindow").window("close");
	$("#roleName").val("");
	$("#roleId").val("");
	
});

/**
 * 修改按钮绑定事件
 */
$("#dop_btn_modify").click(function() {
	isModify=true;
	userError.hide();
	var selections = $("#dop_datagrid_deliveryMan").datagrid(
			"getSelections");
	if (selections.length>0) {
		if (selections.length > 1) {
			layer.tips('请选择一行数据', this, {
				guide : 2,
				time : 2,
				more:true
			});
		} else {
			/*
			var index= $.layer({
				type:3,
				title: '正在加载信息...',
				loading: {
				    type: 0
				}
			});
			*/
			var index=layer.load('正在加载信息...');
			EapTools.doAction("deliveryCompanyController.do?loadRole", {"manId":selections[0].id},
				true, function(data) {
					layer.close(index);
					$("#loginPwd,#loginRepwd").hide();
					oldDelcer=selections[0].delCertificates;
					$("#delId").val(selections[0].id);
					$("#realName").val(selections[0].sUserName);
					$("#delCertificates").val(selections[0].delCertificates);
					$("#delTelephone").val(selections[0].delTelephone);
					$("#delIntroduction").val(selections[0].delIntroduction);
					$("#userName").hide();
					var label=$("#userNameLabel");
					label.text(data.loginUserName);
					label.show();
					$("#roleId").val(data.roleId);
					$("#roleName").val(data.roleName);
					$("#isDeliveryMan").combobox("setValue",selections[0].isDeliveryMan);
					$("#window").window("open");
					
				});
		}
	} else
		layer.tips('请选择要修改行', this, {
			guide : 2,
			time : 2,
			more:true
		});
});


		
/**
 * 添加按钮绑定事件
 */
$("#dop_btn_showAdd").click(function() {
		userError.show();
		$("#window").window("open");
		$("#delId").val("");
		$("#userName").show();
		$("#userNameLabel").hide();
		$("#loginPwd,#loginRepwd").show();
		oldDelcer="";
		isModify=false;
	});


// bind delete event
$("#dop_btn_deliveryman_delete").click(function() {
	var selections = $("#dop_datagrid_deliveryMan").datagrid("getSelections");
	if (selections && selections.length > 0)
		layer.confirm('确定删除吗？', function() {
			EapTools.doAction("deliveryCompanyController.do?delete", {
				"rowList" : JSON.stringify(selections)
			}, true, function(data) {
				if (data.success) {
					EapTip.msgOk("删除成功！");
					init();
				}
			});
		});
	else
		layer.tips('请选择要删除行', this, {
			guide : 2,
			time : 2,
			more:true
		});
});

/**
 * 启用人员
 */
$("#dop_btn_open").click(function(){
	var selections = $("#dop_datagrid_deliveryMan").datagrid("getSelections");
	if(selections.length > 0){
		layer.confirm('确定要将员工状态改为在职吗？', function() {
			var ids=[];
			for(var i=0;i<selections.length;i++){
				ids.push(selections[i].id);
			}
			EapTools.doAction("deliveryManController.do?open", {
				"ids" : ids
			}, true, function(data) {
				if (data.success) {
					EapTip.msgOk("操作成功！");
					init();
				}else{
					EapTip.msgError("操作失败，请重试！");				
				}
			});
			
		});
	}else{
		layer.tips('请选择要操作的行', this, {
			guide : 2,
			time : 2,
			more:true
		});
	}
});
/**
 * 停用人员
 */
$("#dop_btn_stop").click(function(){
	var selections = $("#dop_datagrid_deliveryMan").datagrid("getSelections");
	if(selections.length > 0){
		layer.confirm('确定要将员工状态改为离职吗？', function() {
			var ids=[];
			for(var i=0;i<selections.length;i++){
				ids.push(selections[i].id);
			}
			EapTools.doAction("deliveryManController.do?stop", {
				"ids" : ids
			}, true, function(data) {
				if (data.success) {
					EapTip.msgOk("操作成功！");
					init();
				}else{
					EapTip.msgError("操作失败，请重试！");				
				}
			});
			
		});
	}else{
		layer.tips('请选择要操作的行', this, {
			guide : 2,
			time : 2,
			more:true
		});
	}
});





/**
 * 校验员工证件编号
 */
var delCertificatesFlag = false;
var oldDelcer="";
function chekcdelCertificates(){
	var reg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
	var val = $.trim($("#delCertificates").val());
	if(val.length==0){
		/*delCertificatesFlag = true;
		//hideErrorMsg("delCertificatesMsg");
		changeErrorClass("delCertificates",1)
		return;*/
		
		delCertificatesFlag=false;
		//showErrorMsg("联系手机号不能为空!","delTelephoneMsg");
		layerComm("身份证号不能为空!","delCertificates");
		changeErrorClass("delCertificates",2)
		return;
	}
	if(oldDelcer==val){
		delCertificatesFlag = true;
		//hideErrorMsg("delCertificatesMsg");
		changeErrorClass("delCertificates",1)
		return ;
	} else if (reg.test(val)) {
		delCertificatesFlag=true;
		changeErrorClass("delCertificates",1);
		
		var isDeliveryMan=$("#isDeliveryMan").combobox("getValue");
		EapTools.doAction("deliveryCompanyController.do?chekcDelCertificates", {
			companyId:$("#companyId").val(),
			delId:$.trim($("#delId").val()),
			realName : $.trim($("#realName").val()),
			delCertificates:$.trim($("#delCertificates").val()),
			delTelephone:$.trim($("#delTelephone").val()),
			delIntroduction:$.trim($("#delIntroduction").val()),
			isDeliveryMan:isDeliveryMan,
			userName:$.trim($("#userName").val()),
			password:$.trim($("#password").val()),
			roleId:$.trim($("#roleId").val())
		},false,function(data) {
					debugger;
					delCertificatesFlag=data.success;
					if(!data.success){
						//showErrorMsg("该证件编号已经存在，不能重复添加！","delCertificatesMsg");
						var infomap = data.attributes;
						if(infomap.postmansize == 1){
							layerComm("第三方的配送人员数据有误，不能完成添加！","delCertificates");
						}
						if(infomap.deliverymansize == 1){
							layerComm("该证件编号已经存在，不能重复添加！","delCertificates");
						}
						changeErrorClass("delCertificates",2)
					}else{
						//hideErrorMsg("delCertificatesMsg");
						changeErrorClass("delCertificates",1)
					}
			});
		  
	} else {
		delCertificatesFlag = false;
		//showErrorMsg("编号格式只能为字母和数字！","delCertificatesMsg");
		layerComm("身份证号格式不正确！","delCertificates");
		changeErrorClass("delCertificates",2)
	}
}
/**
 * 验证员工电话
 */
var delTelephoneFlag=false;
function checkdelTelephone(){
	var reg=/^1[3|4|5|8][0-9]\d{8}$/;
	var tel=$.trim($("#delTelephone").val());
	if(tel.length==0){
		delTelephoneFlag=false;
		//showErrorMsg("联系手机号不能为空!","delTelephoneMsg");
		layerComm("联系手机号不能为空!","delTelephone");
		changeErrorClass("delTelephone",2)
		return;
	}else if(!reg.test(tel)){
		delTelephoneFlag=false;
		//showErrorMsg("请输入正确格式的手机号!","delTelephoneMsg");
		layerComm("请输入正确格式的手机号!","delTelephone");
		changeErrorClass("delTelephone",2)
		return;
	}
	//hideErrorMsg("delTelephoneMsg");
	delTelephoneFlag=true;
	changeErrorClass("delTelephone",1)
}
/**
 * 校验员工姓名
 */
var realNameFlag=false;
function chekcRealName(){
	var val = $.trim($("#realName").val());
	if(val.length==0){
		realNameFlag=false;
		//showErrorMsg("员工姓名不能为空!","realNameMsg");
		layerComm("员工姓名不能为空!","realName");
		changeErrorClass("realName",2)
	}else if (val.length > 50) {
		realNameFlag = false;
		//showErrorMsg("员工姓名不得超过20个字符!","realNameMsg");
		layerComm("员工姓名不得超过20个字符!","realName");
		changeErrorClass("realName",2)
	}else{
		realNameFlag=true;
		//hideErrorMsg("realNameMsg");
		changeErrorClass("realName",1)
	} 
}

/**
 * 验证人员描述
 */
var delIntroductionFlag=false;
function checkDelIntroduction(){
	var val=$.trim($("#delIntroduction").val());
	if(val.length>200){
		delIntroductionFlag=false;
		//showErrorMsg("员工备注不得超过200个字符!","delIntroductionMsg");
		layerComm("备注不得超过200个字符!","delIntroduction");
		changeErrorClass("delIntroduction",2)
	}else{
		delIntroductionFlag=true;
		//hideErrorMsg("delIntroductionMsg");
		changeErrorClass("delIntroduction",1)
	}
}


/**
 * 验证角色
 */
var roleFlag=false;
function checkRole(){
	var role=$.trim($("#roleId").val());
	if(role.length==0){
		//showErrorMsg("请选择角色!","roleNameMsg");
		layerComm("请选择角色!","roleName");
		changeErrorClass("roleName",2)
		roleFlag=false;
		return;
	}
	//hideErrorMsg("roleNameMsg");
	roleFlag=true;
	changeErrorClass("roleName",1)
}
/**
 * 验证用户名
 */
var userNameFlag=false;
function checkUserName(){
	var userName=$.trim($("#userName").val());
	if(userName.length<2||userName.length>10){
		//showErrorMsg("用户名在2-10个字符!","userNameMsg");
		layerComm("用户名在2-10个字符!","userName");
		changeErrorClass("userName",2)
		userNameFlag=false;
		return;
	}else{
		/**
		 * 验证唯一性
		 */
		EapTools.doAction("deliveryCompanyController.do?checkUserName",	{"userName":userName},
			false,
			function(data) {
				if(data==false){
					//showErrorMsg("该用户已存在，不能重复添加!","userNameMsg");
					layerComm("该用户已存在，不能重复添加!","userName");
					changeErrorClass("userName",2)
					userNameFlag=false;
				}else{
					userNameFlag=true;
					//hideErrorMsg("userNameMsg");
					changeErrorClass("userName",1)
				}
			});
	}
}

/**
 * 验证密码
 */
var passWordFlag=false;
function checkPassWord(){
	var pwd=$.trim($("#password").val());
	if(pwd.length<6||pwd.length>18){
		//showErrorMsg("密码格式为6-18个字符！","passwordMsg");
		layerComm("密码格式为6-18个字符！","password");
		changeErrorClass("password",2)
		passWordFlag=false;
		return;
	}
	//hideErrorMsg("passwordMsg");
	passWordFlag=true;
	changeErrorClass("password",1)
}

/**
 * 判断重复密码
 */
var repasswordFlag=false;
function checkRepassword(){
	var pwd=$.trim($("#password").val());
	var rePwd=$("#repassword").val();
	if(pwd.length>0){
		if(rePwd.length==0){
			repasswordFlag=false;
			//showErrorMsg("请输入重复密码！","repasswordMsg");
			layerComm("请输入重复密码！","repassword");
			changeErrorClass("repassword",2)
			return;
		}
		if(pwd==rePwd){
			repasswordFlag=true;
			//hideErrorMsg("repasswordMsg");
			changeErrorClass("repassword",1)
		}else{
			repasswordFlag=false;
			//showErrorMsg("两密码不一致！","repasswordMsg");
			layerComm("两密码不一致！","repassword");
			changeErrorClass("repassword",2)
		}
	}
}
/***
 * layer提示信息封装
 * @param msg  消息内容
 * @param id   要显示位置的元素ID
 */
function layerComm(msg,id){
	layer.tips(msg, document.getElementById(id), {
		guide : 1,
		time : 2,
		more:true
	});
}

/**
 * 显示错误信息
 */
function showErrorMsg(errorMsg,eleId){
	var msg=$("#"+eleId);
	msg.html(errorMsg);
	msg.show();
}

/**
 * 修改input错误和成功时的样式
 * @param {} id  元素ID
 * @param {} type  类型  1：success，2：error
 */
function changeErrorClass(id,type){
	var obj=$("#"+id);
	if(type==1){
		obj.attr("class","textbox");
	}else{
		obj.attr("class","textbox validatebox-invalid");
	}
}

/**
 * 隐藏错误信息
 */
function hideErrorMsg(eleId){
	$("#"+eleId).hide();
}
/**
 * 绑定keydown事件,只允许输入数字
 */
$("input[code='delMaxmum'],#delTelephone").keydown(function(e){
	e = e || event;	
	var code=e.keyCode;
	return (code>36&&code<41)||(code>45&&code<58)||(code>95&&code<107)||code==8||code==9;
});

/**
 * 绑定失焦事件
 */
$("#realName").blur(function(){
	chekcRealName();
});
$("#delTelephone").blur(function(){
	checkdelTelephone();
});
$("#delCertificates").blur(function(){
	chekcdelCertificates();
});
$("#delIntroduction").blur(function(){
	checkDelIntroduction();
});
$("#userName").blur(function(){
	checkUserName();
});
$("#password").blur(function(){
	checkPassWord();
});
$("#repassword").blur(function(){
	checkRepassword();
});
$("#roleName").blur(function(){
	checkRole();
});
$("#roleName").click(function(){
	selectRole();
});
/**
 * 给company绑定失去焦点事件
 */
$("#companyName").blur(function(){
	checkCompanyName();
});
/**
 * 添加员工面板 确定按钮
 */
$("#save").click(
		function() {
			var isDeliveryMan=$("#isDeliveryMan").combobox("getValue");
			var companyName = $("input[id='companyName']").val();
			chekcRealName();
			checkdelTelephone();
			checkRole();
			chekcdelCertificates();
			checkDelIntroduction();
			/**
			 * 如果是修改只验证部分内容，否则验证全部
			 */
			if(isModify){
				if(!(realNameFlag&&roleFlag&&delTelephoneFlag&&delIntroductionFlag&&delCertificatesFlag&&roleFlag)){
					return;
				}
			}else{
				checkPassWord();
				checkRepassword();
				checkUserName();
				if(!(realNameFlag&&roleFlag&&delTelephoneFlag&&delIntroductionFlag&&delCertificatesFlag&&userNameFlag&&roleFlag&&passWordFlag&&repasswordFlag)){
					return;
				}
			}
			
			EapTools.doAction("deliveryCompanyController.do?saveOrUpdateMan", {
				companyId:$("#companyId").val(),
				delId:$.trim($("#delId").val()),
				realName : $.trim($("#realName").val()),
				delCertificates:$.trim($("#delCertificates").val()),
				delTelephone:$.trim($("#delTelephone").val()),
				delIntroduction:$.trim($("#delIntroduction").val()),
				isDeliveryMan:isDeliveryMan,
				userName:$.trim($("#userName").val()),
				password:$.trim($("#password").val()),
				roleId:$.trim($("#roleId").val())
			}, true, function(data) {
				/**
				 * 如果成功了，初始化控件并刷新页面
				 */
				if(data.success){
					EapTip.msgOk("操作成功！");
					$("#window").window("close");
					$("#delId").val("");
					$("#realName").val("");
					$("#delCertificates").val("");
					$("#delTelephone").val("");
					$("#delIntroduction").val("");
					$("#userName").val("");
					$("#password").val("");
					$("#roleId").val("");
					$("#roleName").val("");
					$(".Validform_wrong").hide();
					$(".textbox").attr("class","textbox");
					init();
				}else{
					EapTip.alertError("操作失败，请重试！");
				}
			});
		});

// 添加面板 取消按钮
$("#cancel").click(function() {
	$("#window").window("close");
	$("#window").find("input[class='textbox'],textarea").val("");
	$(".textbox").attr("class","textbox");
	$(".Validform_wrong").hide();
});

/**
 * 验证公司电话
 */
var telFlag=false;
function checkCompanyTel(){
	var reg=/^1[3|4|5|8][0-9]\d{8}$/;
	var tel=$.trim($("#companyTel").val());
	if(tel.length==0){
		telFlag=true;
		changeErrorClass("companyTel",1)
		//showErrorMsg("联系电话不能为空！","companyTelMsg");
	}else if(tel.length>20){
		telFlag=false;
		layerComm("电话长度过长！","companyTel");
		changeErrorClass("companyTel",2)
		return;
	}
	changeErrorClass("companyTel",1)
	telFlag=true;
}

/**
 * 验证公司名称
 */
var companyNameFlag=false;
function checkCompanyName(){
	var val=$.trim($("#companyName").val());
	if(val.length==0){
		companyNameFlag=false;
		layerComm("公司名称不得为空！","companyName");
		changeErrorClass("companyName",2)
	}else if(val.length>200){
		companyNameFlag=false;
		layerComm("公司名称不得超过100个字符！","companyName");
		changeErrorClass("companyName",2)
	}else{
		companyNameFlag=true;
		changeErrorClass("companyName",1)
		
		var isDeliveryMan=$("#isDeliveryMan").combobox("getValue");
		EapTools.doAction("deliveryCompanyController.do?chekcCompanyName", {
			id:$("#companyId").val(),
			companyName : $.trim($("#companyName").val()),
			companyTel:$.trim($("#companyTel").val()),
			companyDesc:$.trim($("#companyDesc").val())
		},false,function(data) {
					//debugger;
					companyNameFlag=data.success;
					if(!data.success){
						//debugger;
						var infomap = data.attributes;
						if(infomap.expresscompanysize == 1){
							layerComm("第三方的公司数据有误，不能完成添加！","companyName");
						}
						if(infomap.deliverycompanysize == 1){
							layerComm("该公司名已经存在，不能重复添加！","companyName");
						}
						changeErrorClass("companyName",2)
					}else{
						//hideErrorMsg("delCertificatesMsg");
						changeErrorClass("companyName",1)
					}
			});
		
	}
}

/**
 * 验证公司备注
 */
var companyDescFlag=false;
function checkCompanyDesc(){
	var desc=$.trim($("#companyDesc").val());
	if(desc.length>300){
		layerComm("公司备注不得超过300个字符！","companyDesc");
		changeErrorClass("companyDesc",2)
		companyDescFlag=false;
		return;
	}
	companyDescFlag=true;
	changeErrorClass("companyDesc",1)
}

$("#dop_deliveryCompany_save").click(
	function() {
		var companyName = $("input[id='companyName']").val();
		//先调用方法进行校验
		checkCompanyName();
		checkCompanyTel();
		checkCompanyDesc();
		if (!(companyNameFlag&&telFlag&&companyDescFlag)) {
			layerComm("信息添写有误，无法提交！","dop_deliveryCompany_save");
			return;
		}
		EapTools.doAction("deliveryCompanyController.do?saveOrUpdate", {
			id:$("#companyId").val(),
			companyName : $.trim($("#companyName").val()),
			companyTel:$.trim($("#companyTel").val()),
			companyDesc:$.trim($("#companyDesc").val())
		}, true, function(data) {
			if(data.success){
				EapTip.msgOk("操作成功！");
			}else{
				EapTip.alertError("操作失败，请重试！");
			}
		});
	});

// bind query event
$("#dop_btn_query").click(function() {
	init();
});

/*
// 绑定用户列表
EapTools.doAction("deliveryCompanyController.do?users", {}, false, function(data) {
	var selectorArray = [];
	selectorArray.push("<option value=''>---请选择---</option>");
	for (var i = 0; i < data.length; i++) {
		var thisObj = data[i];
		selectorArray.push("<option value='", thisObj.ID, "'>",
				thisObj.realname, "</option>");
	}
	$("select[id='sUser']").append(selectorArray.join(""));
});
*/
// get params
function getQueryParams() {
	return {
		delName : $("input[code='realName']").val(),
		companyId:$("#companyId").val()
		};
}

// init
function init() {
	// init
	var options = $("#dop_datagrid_deliveryMan").datagrid('getPager').data(
			"pagination").options;
	var pageSize = options.pageSize;
	var params = $.extend({
		pageNum : 1,
		pageSize : pageSize
	}, getQueryParams());
	EapTools.doAction("deliveryCompanyController.do?queryManList", params, true,
			function(data) {
				$("#dop_datagrid_deliveryMan").datagrid('loadData', {
					"rows" : data.list,
					"total" : data.count
				} || {});
				var p = $("#dop_datagrid_deliveryMan").datagrid('getPager');
				$("td:last", p).find("a").click();
			});
}
/**
 * 为input绑定change事件 
 */
$("input[code='realName']").on("input",function(){
	init();
});
$("input[code='roleName']").on("input",function(){
	initRole();
});


